{include file="public/top" /}

<body>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>用户名
            </label>
            <div class="layui-input-block">
                <input type="text" id="username" name="username" value="{$Think.session.admin_name}" disabled  required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
            <br>
            <label class="layui-form-label">
                <span class="x-red">*</span>原密码
            </label>
            <div class="layui-input-block">
                <input type="text" id="password" name="password" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
            <br>
            <label class="layui-form-label">
                <span class="x-red">*</span>新密码
            </label>
            <div class="layui-input-block">
                <input type="text" id="passwordnew" name="passwordnew" required="" lay-verify="repass"
                       autocomplete="off" class="layui-input">
            </div>
            <br>
            <label class="layui-form-label">
                <span class="x-red">*</span>确认新密码
            </label>
            <div class="layui-input-block">
                <input type="text" id="passwordnew1" name="passwordnew1" required="" lay-verify="repass"
                       autocomplete="off" class="layui-input">
            </div>



        </div>

        <div class="layui-form-item">
            <button type="button"  class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">提交</button>
        </div>
    </form>
</div>
<script>

    var addurl = '/admin/index/change';
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            repass: function(value){
                if($('#passwordnew').val()!=$('#passwordnew1').val()){
                    return '新密码两次密码不一致';
                }
            }
        });
        //监听提交
        form.on('submit(add)', function(data){
            $.post(addurl, data.field,function(res) {
                var success = JSON.parse(res);
                if(success.code===200){
                    layer.msg(success.msg, {
                        time: 1000, //不自动关闭
                        icon:6,
                        end:function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }
                    });
                    return false;
                }else {
                    layer.msg(success.msg)
                }

            });

        });
    });

</script>


</body>

</html>